package com.cxd.service.impl;

import com.cxd.entity.EbNews;
import com.cxd.mapper.EbNewsMapper;
import com.cxd.service.IEbNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EbNewsServiceImpl implements IEbNewsService {
    @Autowired
    private EbNewsMapper newsMapper;

    @Override
    public List<EbNews> listByPage(Integer page, Integer pageSize) {
        System.out.println("Service层--->调用了Service的listByPage方法");
        int from = (page - 1) * pageSize;
        return newsMapper.findByPage(from, pageSize);
    }

    @Override
    public Integer findTotalPage(Integer pageSize) {
        return newsMapper.getTotalPage(pageSize);
    }

    @Override
    public Integer save(EbNews ebNews) {
        return newsMapper.save(ebNews);
    }

    @Override
    public EbNews selectOne(Integer enId){
        return newsMapper.selectOne(enId);
    }
    @Override
    public Integer updateNews(EbNews ebNews){
        return newsMapper.updateByPrimaryKey(ebNews);
    }

    @Override
    public int deleteByPk(int id) {
        return newsMapper.deleteByPk(id);
    }
}
